home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / zoo tutorial / module10- qtzoo / source / zoo.java < prev    next >
Encoding:
Java Source  |  2000-06-23  |  2.7 KB  |  115 lines

  1. import java.awt.Color;
  2. import java.awt.GridBagLayout;
  3. import java.awt.GridBagConstraints;
  4.  
  5. import quicktime.QTSession;
  6. import quicktime.QTException;
  7. import quicktime.app.display.FullScreenWindow;
  8. import quicktime.std.movies.FullScreen;
  9.  
  10. import com.apple.mrj.MRJApplicationUtils;
  11. import com.apple.mrj.MRJQuitHandler;
  12.  
  13.  
  14. /**
  15.  * QTZoo Module 9 - Using Full Screen Mode
  16.  * This application requires QuickTime for Java
  17.  *
  18.  * @author Levi Brown
  19.  * @author Michael Hopkins
  20.  * @author Apple Computer, Inc.
  21.  * @version 9.0 4/10/2000
  22.  * 
  23.  */
  24.  
  25. public class Zoo implements MRJQuitHandler, Runnable //!! added Runnable !!
  26. {
  27.     /**
  28.      *  Zoo constructor
  29.      */
  30.     public Zoo() 
  31.     {
  32.         MRJApplicationUtils.registerQuitHandler(this);            // register handler for command-Q
  33.         
  34.         //-- Create new progress bar object                       --
  35.         //-- Insert "1 Zoo- create progress" source clipping here --
  36.         try
  37.         {
  38.             window = new FullScreenWindow(new FullScreen());    // create a new fullscreen window
  39.             window.setBackground (Color.black);                    // color window black
  40.             
  41.             window.setLayout(new GridBagLayout());
  42.             gbc = new GridBagConstraints();
  43.             gbc.gridx = 1;
  44.             gbc.gridy = 1;
  45.             gbc.gridwidth = 1;
  46.             gbc.anchor = GridBagConstraints.CENTER;
  47.             gbc.fill = GridBagConstraints.NONE;
  48.             
  49.             //-- Add progress object to window                        --
  50.             //-- Insert "3 Zoo- add progress" source clipping here --
  51.  
  52.             window.show();
  53.             //-- Create and start new thread                         --
  54.             //-- Insert "4 Zoo- create thread" source clipping here --
  55.             
  56.             //!! We don't need the following because we are now a runnable !!
  57.             /* run(); */
  58.         }
  59.         catch (QTException exc)
  60.         {
  61.             exc.printStackTrace();
  62.         }
  63.     }
  64.     
  65.     /**
  66.      * Main body of class. Creates main window, and displays it
  67.      */
  68.     public void run()
  69.     {
  70.         mainFrame = new MainFrame(window, progress);
  71.         
  72.         //-- Remove progress bar                                     --
  73.         //-- Insert "5 Zoo- remove progress" source clipping here --
  74.         mainFrame.setVisible(true);
  75.         ((GridBagLayout)window.getLayout()).setConstraints(mainFrame, gbc);
  76.         window.add(mainFrame);
  77.         mainFrame.invalidate();
  78.         window.validate();
  79.     }
  80.     
  81.     /**
  82.      * Handles quitting the application.
  83.      * This routine gets called by the MRJToolkit when the
  84.      * application is about to quit.
  85.      */
  86.     public void handleQuit()
  87.     {
  88.         mainFrame.handleQuit();
  89.     }
  90.  
  91.     /**
  92.      * Main entry point of our program
  93.      */
  94.     static public void main(String[] args) 
  95.     {
  96.         try
  97.         {
  98.             QTSession.open();            // Initialize QuickTime 
  99.             new Zoo( );
  100.         }
  101.         catch (Exception e) 
  102.         {
  103.             e.printStackTrace();
  104.             QTSession.close();            // Shut down QuickTime and dispose of native context
  105.         }
  106.     }
  107.     
  108.     protected MainFrame mainFrame;    
  109.     protected FullScreenWindow window;
  110.     protected GridBagConstraints gbc;
  111.     
  112.     //-- Declare progress object data member                      --
  113.     //-- Insert "2 Zoo- declare progress" source clipping here --
  114. }
  115.